package com.rs.utils;


public abstract class TickEvent {

    private int ticks;

    private int maxTicks;

    private int ticksPassed;

    private String identifier;

    public TickEvent(int maxTicks) {
        this(maxTicks, "");
    }

    public TickEvent(int maxTicks, String identifier) {
        this.maxTicks = maxTicks;
        this.identifier = identifier;
    }

    public abstract boolean finish();

    public boolean isReady() {
        ticks++;
        ticksPassed++;
        if (ticks < maxTicks)
            return false;
        ticks = 0;
        return true;
    }

    public void setMaxTicks(int maxTicks) {
        this.maxTicks = maxTicks;
        ticks = 0;
    }

    public void resetTicks() {
        ticks = 0;
    }

    public boolean isNew() {
        return ticksPassed == 0;
    }

    public int getMaxTicks() {
        return maxTicks;
    }

    public String getIdentifier() {
        return identifier;
    }

}
